﻿namespace Inlycat
{
    /// <summary>
    /// 消息打包数据
    /// </summary>
    public class Telegram
    {
        /// <summary>
        /// 消息ID
        /// </summary>
        private int _id;

        /// <summary>
        /// 下一个消息ID，用于自增长
        /// </summary>
        private static int _nextId;

        /// <summary>
        /// 消息ID
        /// </summary>
        public int ID
        {
            get { return _id; }
        }

        /// <summary>
        /// 发送者实体ID
        /// </summary>
        public int sender;

        /// <summary>
        ///  接收者实体ID
        /// </summary>
        public int receiver;

        /// <summary>
        /// 消息值
        /// </summary>
        public int msg;

        /// <summary>
        /// 发送时间
        /// </summary>
        public double dispatchTime;

        /// <summary>
        /// 额外信息
        /// </summary>
        public object extraInfo;

        /// <summary>
        /// 消息打包数据
        /// </summary>
        /// <param name="sender">发送者实体ID</param>
        /// <param name="receiver">接收者实体ID</param>
        /// <param name="msg">消息值</param>
        /// <param name="dispatchTime">发送时间</param>
        /// <param name="extraInfo">额外信息</param>
        public Telegram(int sender, int receiver, int msg, double dispatchTime = 0, object extraInfo = null)
        {
            this._id = ++_nextId;
            this.sender = sender;
            this.receiver = receiver;
            this.msg = msg;
            this.dispatchTime = dispatchTime;
            this.extraInfo = extraInfo;
        }
    }
}

